package com.kylin.androidlearn1.acticity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.widget.GridView;

import com.kylin.androidlearn1.R;
import com.kylin.androidlearn1.acticity.adapter.GridViewAdapter;
import com.kylin.androidlearn1.acticity.bean.MyEntity;

import java.util.ArrayList;

/**
 * Created by kylinhuang on 10/3/16.
 */
public class Demo1Activity extends Activity {


    private static final String TAG = "Demo1Activity";
    private Context mContext;
    private GridView mGridView;
    private GridViewAdapter mGridViewAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_demo1);
        mContext = this ;




        ArrayList <MyEntity> list =  getData();

        mGridView =  (GridView)findViewById(R.id.grid_view);

        mGridViewAdapter = new GridViewAdapter(mContext,list); //创建适配器
        mGridView.setAdapter(mGridViewAdapter);  //ListView 设置 adapter
        Log.e(TAG,"onCreate");
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.e(TAG,"onStart");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.e(TAG,"onPause");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.e(TAG,"onResume");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.e(TAG,"onStop");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e(TAG,"onDestroy");
    }

    private ArrayList<MyEntity> getData() {
        ArrayList<MyEntity> list = new ArrayList<MyEntity>();
        list.add(new MyEntity("小黄","男","1343i4ou4246"));
        list.add(new MyEntity("小利","男","1343i4ou4246"));

        list.add(new MyEntity("小红","男","1343i4ou4246"));
        list.add(new MyEntity("小黄","男","1343i4ou4246"));

        return list;
    }
}
